﻿@** Copyright 2013 Seven Spikes Ltd. All rights reserved. (http://www.nop-templates.com)
* http://www.nop-templates.com/t/licensinginfo
*@

@model Nop.Web.Models.Catalog.ProductReviewsModel
<div id="updateTargetId" class="product-reviews-page">
    @if (Model.AddProductReview.SuccessfullyAdded)
    {
        @Model.AddProductReview.Result
    }
    else
    {
        <div class="write-review" id="review-form">
            <div class="title">
                <strong>@T("Reviews.Write")</strong>
            </div>

            <div class="message-error">@Html.ValidationSummary(true)</div>
            <div class="form-fields">
                <div class="inputs">
                            @Html.LabelFor(model => model.AddProductReview.Title, new { }, ":")
                    @Html.TextBoxFor(model => model.AddProductReview.Title, Model.AddProductReview.CanCurrentCustomerLeaveReview ? (object)(new { @class = "review-title" }) : (object)(new { @class = "review-title", disabled = "disabled" }))
                    @Html.ValidationMessageFor(model => model.AddProductReview.Title)
                </div>
                <div class="inputs">
                            @Html.LabelFor(model => model.AddProductReview.ReviewText, new { }, ":")
                    @Html.TextAreaFor(model => model.AddProductReview.ReviewText, Model.AddProductReview.CanCurrentCustomerLeaveReview ? (object)(new { @class = "review-text" }) : (object)(new { @class = "review-text", disabled = "disabled" }))
                    @Html.ValidationMessageFor(model => model.AddProductReview.ReviewText)
                </div>
                <div class="review-rating">
                            @Html.LabelFor(model => model.AddProductReview.Rating, new { }, ":")
                    <ul>
                        <li class="first">@T("Reviews.Fields.Rating.Bad")</li>
                        <li>
                            @Html.RadioButtonFor(model => model.AddProductReview.Rating, "1")
                            @Html.RadioButtonFor(model => model.AddProductReview.Rating, "2")
                            @Html.RadioButtonFor(model => model.AddProductReview.Rating, "3")
                            @Html.RadioButtonFor(model => model.AddProductReview.Rating, "4")
                            @Html.RadioButtonFor(model => model.AddProductReview.Rating, "5")
                        </li>
                        <li class="last">@T("Reviews.Fields.Rating.Excellent")</li>
                    </ul>
                </div>
                @if (Model.AddProductReview.DisplayCaptcha)
                {
                    <div class="captcha-box">
                        @Html.Raw(Html.GenerateCaptcha())
                    </div>
                }
            </div>
            <div class="buttons">
                @if(Model.AddProductReview.CanCurrentCustomerLeaveReview)
                {
                    <input type="button" id="add-review" name="add-review" class="button-1 write-product-review-button" value="@T("Reviews.SubmitButton")" />
                }else
                {
                    <input type="button" id="add-review" disabled="disabled" name="add-review" class="button-1 write-product-review-button" value="@T("Reviews.SubmitButton")" />
                }
            </div>

        </div>        
    }
    @if (Model.Items.Count > 0)
    {
        <div class="product-review-list">
            <div class="title">
                <strong>@T("Reviews.ExistingReviews")</strong>
            </div>
            @foreach (var review in Model.Items)
            {
                int ratingPercent = review.Rating * 20;
                
                <div class="product-review-item">
                    <div class="review-item-head">
                        <div class="review-title">
                            <strong>@review.Title</strong>
                        </div>
                            <div class="product-review-box">
                        <div class="rating">
                            <div style="width: @(ratingPercent)%">
                            </div>
                        </div>

                    </div>
                    </div>
                    <div class="review-text">
                        @Html.Raw(Nop.Core.Html.HtmlHelper.FormatText(review.ReviewText, false, true, false, false, false, false))
                    </div>
                        <div class="review-info">
                        <span class="user">
                            <strong>@T("Reviews.From"):</strong>
                            @if (review.AllowViewingProfiles)
                            {
                                <a href="@Url.RouteUrl("CustomerProfile", new { id = review.CustomerId })">@(review.CustomerName)</a>
                            }
                            else
                            {
                                @review.CustomerName
                            }
                        </span>
                        <span class="separator">|</span>

                        <span class="date">
                            <strong>@T("Reviews.Date"):</strong>
                            @review.WrittenOnStr
                        </span>
                    </div>
                    @Html.Partial("_ProductReviewHelpfulness", review.Helpfulness, new ViewDataDictionary())
                    @Html.Widget("productreviews_page_inside_review")
                </div>
            }
        </div>
    }
</div>
